package docmodel;

import java.util.LinkedList;

/**
 * Mantiene la lista di Campi di un documento, evita di inserire duplicati
 * 
 * @author andrea
 *
 */
public class XDP_Liste {
	
	/** */
	public LinkedList<Field> listaFields;
	
	/** */
	public LinkedList<String> listaDataPDF;
	
	/**
	 * 
	 */
	public XDP_Liste() 
	{	
		listaFields = new LinkedList<Field>();
		listaDataPDF		= new LinkedList<String>();
	}

	/**
	 * 
	 * @param field
	 */
	public void aggiungi_field(Field field ) 
	{	
		for(Field ff : listaFields) 
		{	
			if(ff.getId().equals(field.getId()))    //evita duplicati
				return; 
		}
		listaFields.add(field);
		
		//P
		//System.out.println("field aggiunto");
	}

	public void aggiungi_dataPDF_Element(String elem ) 
	{	

		listaDataPDF.add(elem);
		
		//P
		//System.out.println("elemento DataPDF aggiunto");
	}
	
	/**
	 * 
	 */
	public void stampa_lista()
	{
		//P
		System.out.println("******************************");	
		for(Field ff : listaFields) {	
			System.out.println(ff.getId());	
		}
		//P
		System.out.println("******************************\n\n");
		
		
		//P
		System.out.println("******************************");	
		for(String elem : listaDataPDF) {	
			System.out.println(elem);	
		}
		//P
		System.out.println("******************************\n\n");
	}
	
	public void stampa_lista(StringBuffer sb)
	{
		sb.append("\n******************************");	
		for(Field ff : listaFields) {	
			sb.append("\n"+ ff.getName()+" / "+ ff.getCode()+ " / ");	
		}
		//P
		sb.append("\n******************************\n\n");
	}
	
}